var mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/customers");
var db = mongoose.connection;
db.on("error",function()
{
	console.log("数据库连接失败");
});
db.on("open",function()
{
	console.log("数据库连接成功");
});

var Schema = mongoose.Schema;
var customerSchema = new Schema(
{
	name: String,
	cipher: String,
	tel: Number
},{collection:"customer"});
var Customer = mongoose.model("Customer",customerSchema);

var goodsSchema=new Schema({
	goodsPic:String,
	goodsName:String,
	goodsNum:Number,
	goodsPrice:String,
	userId:{type:Schema.Types.ObjectId,ref:"customer"}
},{collection:"AllGood"});
var Goods=mongoose.model("goods",goodsSchema);

module.exports={Customer:Customer,Goods:Goods};